package com.qk.management.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author kaoM1Jy
 * @date 2025/10/17 11:45
 * @description:
 */
@Aspect
@Component
@Slf4j

public class TimeCountAspect {

    @Pointcut("execution(* com.qk.management.controller.*.*(..))")
    public void pt(){
    }

    @Around("pt()")
    public Object around(ProceedingJoinPoint jpt) throws Throwable {
        long start = System.currentTimeMillis();
        Object proceed = jpt.proceed();
        long end = System.currentTimeMillis();
        String className = jpt.getTarget().getClass().getName();
        String methodName = jpt.getSignature().getName();
        log.info("{}中的方法{}方法耗时:{}ms", className, methodName, end - start);
        return proceed;
    }

}
